<%--
  Created by IntelliJ IDEA.
  User: bin.liu
  Date: 2018/12/5
  Time: 11:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="/pages/sysIndex/default.jsp"/>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<div class="main-content">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-tools pull-right">
                <a href="#" class="btn btn-default" id="btnSearch" title="查询"><i class="fa fa-filter"></i> 查询</a>
            </div>
        </div>

        <div class="box-body">
            <form id="searchForm" action="<c:url value="/web/admin/plannerOrder/orderJson.action"/>" method="post"
                  class="form-inline hide" data-page-no="1" data-page-size="20" data-order-by="">
                <div class="form-group">
                    <label class="control-label">搜索：</label>
                    <div class="control-inline">
                        <input type="text" id="searchCode" name="searchCode" value="" maxlength="64"
                               class="form-control width-120">
                        <input type="hidden" id="plannerId" name="plannerId" value="${plannerId}">
                    </div>
                </div>

                <div class="form-group">
                    <button type="submit" class="btn btn-primary btn-sm">查询</button>
                    <button type="reset" class="btn btn-default btn-sm">重置</button>
                </div>
            </form>
            <div style="overflow-x:auto">
                <table id="dataGrid"></table>
            </div>
            <div id="dataGridPage"></div>
        </div>
    </div>
</div>
<script>
    var selectIds = [];
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        shrinkToFit: false,
        autoScroll: true,

        columnModel: [
            {header: 'id', name: 'id', index: 'id', width: 150, align: "center", sortable: false},
            {header: '工单号', name: 'orderCode', index: 'orderCode', width: 150, align: "center", sortable: false},
            {header: '工单名', name: 'orderName', index: 'orderName', width: 250, align: "center", sortable: false},
            {header: '工单类型', name: 'orderType', index: 'orderType', width: 150, align: "center", sortable: false},
            {header: '紧急程度', name: 'degree', index: 'degree', width: 150, align: "center", sortable: false},
            {header: '是否指派', name: 'assignType', index: 'assignType', width: 150, align: "center", sortable: false},
            {header: '工单状态', name: 'orderStatus', index: 'orderStatus', width: 150, align: "center", sortable: false},
            {header: '开始时间', name: 'startDateTime', index: 'startDateTime', width: 250, align: "center"},
            {header: '结束时间', name: 'endDateTime', index: 'endDateTime', width: 150, align: "center", sortable: false},
            {header: '发布状态', name: 'pushStatus', index: 'pushStatus', width: 100, align: "center", sortable: false},
            {header: '发布人',name: 'pushPerson', index: 'pushPerson',    width: 100, align: "center", sortable: false},
            {header: '发布时间', name: 'pushTime', index: 'pushTime',  width: 150, align: "center", sortable: false},
            {header: '撤回人', name: 'revokePerson', index: 'revokePerson', width: 100, align: "center", sortable: false},
            {header: '撤回时间', name: 'revokeTime', index: 'revokeTime', width: 150, align: "center", sortable: false,},
            {header: '工单负责人', name: 'receiveUserName', index: 'receiveUserName', width: 100, align: "center", sortable: false},
            {header: '是否接单', name: 'receive', index: 'receive', width: 100, align: "center", sortable: false},
            {header: '接单人', name: 'receiveUserName', index: 'receiveUserName', width: 100, align: "center", sortable: false},
            {header: '接单日', name: 'receiveDate', index: 'receiveDate', width: 150, align: "center", sortable: false},
            {
                header: '开始时间',
                name: 'startDateTime',
                index: 'startDateTime',
                width: 250,
                align: "center",
                sortable: false
            },
            {header: '完成人', name: 'completeUsers', index: 'completeUsers', width: 150, align: "center", sortable: false},
            {header: '完成时间', name: 'finishTime', index: 'finishTime', width: 150, align: "center", sortable: false},
            {header: '是否完成', name: 'complete', index: 'complete', width: 100, align: "center", sortable: false},
            {header: '执行结果', name: 'result', index: 'result', width: 100, align: "center", sortable: false},
            {
                header: '实际工时(分钟)',//TODO
                name: 'totalWorkingHours',
                index: 'totalWorkingHours',
                width: 250,
                align: "center",
                sortable: false
            },
            {header: '初次审核人', name: 'firstPerson', index: 'firstPerson', width: 250, align: "center", sortable: false},
            {header: '初次审核时间', name: 'firstTime', index: 'firstTime', width: 250, align: "center", sortable: false},
            {header: '初次审核状态', name: 'firstOrder', index: 'firstOrder', width: 250, align: "center", sortable: false},
            {header: '初次审核备注', name: 'firstRemark', index: 'firstRemark', width: 250, align: "center", sortable: false},
            {header: '最终审核人', name: 'lastPerson', index: 'lastPerson', width: 250, align: "center", sortable: false},
            {header: '最终审核时间', name: 'lastTime', index: 'lastTime', width: 250, align: "center", sortable: false},
            {header: '最终审核状态', name: 'lastOrder', index: 'lastOrder', width: 250, align: "center", sortable: false},
            {header: '最终审核备注', name: 'lastRemark', index: 'lastRemark', width: 250, align: "center", sortable: false},
            {
                header: '未完成原因分类',
                name: 'cancelType',
                index: 'cancelType',
                width: 250,
                align: "center",
                sortable: false
            },
            {header: '未完成原因', name: 'cancelReason', index: 'cancelReason', width: 250, align: "center", sortable: false},
            // {
            //     header: '调整预计完成工时',
            //     name: 'endDateTime',
            //     index: 'endDateTime',
            //     width: 250,
            //     align: "center",
            //     sortable: false
            // },
            {header: '调整人', name: 'delayPerson', index: 'delayPerson', width: 250, align: "center", sortable: false},
            {header: '调整日', name: 'delayTime', index: 'delayTime', width: 250, align: "center", sortable: false},
            {header: '调整原因分类', name: 'delayType', index: 'delayType', width: 250, align: "center", sortable: false},
            {header: '调整原因', name: 'delayReason', index: 'delayReason', width: 250, align: "center", sortable: false},
            {header: '所属部门', name: 'organizationName', index: 'organizationName', width: 250, align: "center", sortable: false},
            {
                header: '所属企业',
                name: 'enterpriseName',
                index: 'enterpriseName',
                width: 250,
                align: "center",
                sortable: false
            },


        ],
        ajaxSuccess: function (data) {
            $.each(data.list, function (i, item) {
                var pushPerson;
                var pushDate;
                var person;
                var time;

                $.ajax({//发布信息
                    type: 'post',
                    url: "<c:url value="/web/admin/maintainLog/getLogInfo.action" />",
                    data: {"orderId": item.id,"type":"RELEASE_ORDER","status":"frist"},
                    dataType: 'json',
                    async: false,
                    success: function (data) {
                        pushPerson = data.data.person;
                        pushDate=data.data.timing;
                    },
                });
                $.ajax({//撤回信息
                    type: 'post',
                    url: "<c:url value="/web/admin/maintainLog/getLogInfo.action" />",
                    data: {"orderId": item.id,"type":"WITHDRAW_ORDER","status":"frist"},
                    dataType: 'json',
                    async: false,
                    success: function (data) {
                        person = data.data.person;
                        time = data.data.timing;
                    },
                });
                $("#dataGrid").jqGrid('setCell',item.id ,"pushPerson",pushPerson);
                $("#dataGrid").jqGrid('setCell',item.id ,"pushTime",pushDate);
                $("#dataGrid").jqGrid('setCell',item.id ,"revokePerson",person);
                $("#dataGrid").jqGrid('setCell',item.id ,"revokeTime",time);
            })

        }

    });

</script>
